#ifndef __SYSLOG_H
#define __SYSLOG_H

#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>

#define USE_TCP_FLAG 1


enum OPT_TYPE{ 
    OPT_ADD_LOG = 0,
    OPT_DEL_LOG,
    OPT_CLEAR_LOG,
    OPT_QUERY_LOG
};

enum LOG_LEVEL {
    DEBUG_LEVEL = 0,
    INFO_LEVEL,
    WARN_LEVEL,
    ERROR_LEVEL,
    FATAL_LEVEL,
    MAX_LOG_LEVEL
}; 

typedef struct logCommStruct
{
    unsigned char optType;  // OPT_TYPE
    char allDataInfo[600];  // (char *)struct LOG_INFO_STU
}LOG_COMM_STU;


typedef struct logQueryStruct
{
    unsigned char type; // LOG_LEVEL
    int nCount;
    char startDateTimeArr[20];  // "YYYY-MM-DD HH:MM:SS"
    char endDateTimeArr[20];
    char keyword[50];
}LOG_QUERY_STU;

typedef struct logDeleteStruct
{
    unsigned char type; // LOG_LEVEL
    int nCount;
}LOG_DEL_STU;

typedef struct logStruct
{
    // date (YYYY/MM/DD)
    char dateArr[11];
    // time (HH:MM:SS)
    char timeArr[9];
    // type
    LOG_LEVEL type;
    // object
    char objectArr[30];
    // detail
    char detailArr[500];
}LOG_INFO_STU;


const int MAX_COMM_SIZE = 1024;
const int MAX_DATA_SIZE = 1000;

typedef struct NetworkCommStruct
{
    bool bLastFlag;
    int nSize;    
    char cStrDataBuff[MAX_DATA_SIZE];
}NETWORK_COMM_STU;


class CSysLog
{
public:
    static int SysLogOut(const char* logBuff,...);

    static void LogBackupFunc();
    static char *GetTimeStrNow();


    static bool SaveLog2File();

};


#endif